import Cookie from 'js-cookie'
import Store from '../store'
import { apiUserInfo } from '../api'

export const getCookie = (cookieName: string = "token") => {
    return Cookie.get(cookieName)
}

export const GetUserInfo = async () => {
    if (getCookie()) {
        apiUserInfo().then((res: any) => {
            Store.dispatch({ type: 'USERINFO', payload: res.data })
        })
    }
}